"""
 自动取款机的
 1、菜单
 2、查询余额
 3、取钱
 4、存钱
 5、退出
"""

# 定义用户账户信息列表
customs = [
    {'IDcard': '110101199003076579', 'password': '001000', 'name': 'zhangsan', 'Account': 1000000},
    {'IDcard': '110101199003071655', 'password': '000000', 'name': 'wangwu', 'Account': 105636},
    {'IDcard': '110101199003079657', 'password': '000000', 'name': 'wangshuai', 'Account': 105636}
]


# 菜单
def menu_list():
    print('*' * 40)
    print('{:1} {:10} {:10}'.format(' ', '1、查询余额', '2、取钱'))
    print('{:1} {:10} {:10}'.format(' ', '3、存钱', '4、退出'))
    print('*' * 40)


# 登录
def login():
    for custom in customs:
        if custom['IDcard'] == IDcard and custom['password'] == password:
            print('登录成功!欢迎', custom['name'])
            return True


# 查询余额
def show_account():
    for custom in customs:
        if custom['IDcard'] == IDcard:
            print('您的账户余额为：', custom['Account'], '元人民币。')


# 取钱
def take_the_money():
    money = int(input('请输入您要提取的金额（必须整百）：'))
    for custom in customs:
        if custom['IDcard'] == IDcard:
            custom['Account'] = custom['Account'] - money
            if custom['Account'] > 0:
                print('提取成功，请拿好您的现金!')
                print('您的账户余额为：', custom['Account'], '元人民币。')
            else:
                print('提取失败，您的账户余额不足！')


# 存钱
def saving_money():
    money = int(input('请把面值是百元的钞票叠整齐放入，并输入放入的金额：'))
    for custom in customs:
        if custom['IDcard'] == IDcard:
            custom['Account'] = custom['Account'] + money
            print('您存入的金额为：', money)
            print('您的账户余额为：', custom['Account'], '元人民币。')


# 退出
def login_out():
    print('再见！')


while True:
    print('*' * 40)
    print('{:^25}'.format('欢迎登录ATM自动取款机'))
    print('*' * 40)

    IDcard = input('请输入您的身份证号码：')
    password = input('请输入您的密码：')

    while True:
        if login():

            # 操作菜单
            menu_list()
            key = int(input('请输入需要办理的业务代码：'))
            if key == 1:
                show_account()
            elif key == 2:
                take_the_money()
            elif key == 3:
                saving_money()
            elif key == 4:
                login_out()
                break
            else:
                print('输入有误，请重新输入！')
        else:
            print('身份证号码或者密码错误，请重新输入！')
            break
